package com.mi9688.stream;

import com.mi9688.lambda.Student;

import java.util.Arrays;
import java.util.List;

public class Sum {
    public static void main(String[] args) {

        List<Student> students= Arrays.asList(new Student("小明",18),new Student("小黑",16),new Student("小红",17));
        //创建流并累加年龄
        int sum=students.stream().mapToInt(Student::getAge).sum();
        System.out.println(sum);

    }
}
